//
//  ComicsDetailModel.swift
//  Spookiness
//
//  Created by 腾億 on 2017/12/14.
//  Copyright © 2017年 tml. All rights reserved.
//

import Foundation
import SwiftyJSON

struct DetailStaticModel {
    var chapter_list = [ChapterSatticModel]()
    var otherWorks = [OtherWorksModel]()
    var comic: ComicsStaticModel?
    init(jsonData: JSON) {
        if let chap = jsonData["chapter_list"].arrayObject {
            for item in chap {
                let json = JSON(item)
                let model = ChapterSatticModel(jsonData: json)
                chapter_list.append(model)
            }
        }
        
        if let other = jsonData["otherWorks"].arrayObject {
            for item in other {
                let json = JSON(item)
                let model = OtherWorksModel(jsonData: json)
                otherWorks.append(model)
            }
        }
        
        comic = ComicsStaticModel(jsonData: jsonData["comic"])
        
        
    }
}

struct ComicsStaticModel {
    var accredit: Int = 0
    var author: AuthorModel?
    var cate_id: String?
    var classifyTags = [ClassifyTagModel]()
    var comic_id: Int = 0
    var cover: String?
    var description: String?
    var is_dub: Int = 0
    var is_vip: Int = 0
    var is_week: Int = 0
    var last_update_time: Int = 0
    var last_update_week:String?
    var level: String?
    var name: String?
    var ori: String?
    var series_status: Int = 0
    var short_description: String?
    var status: Int = 0
    var theme_ids: [String]?
    var thread_id: Int = 0
    var type: Int = 0
    var wideCover: String?
    init(jsonData: JSON) {
        accredit = jsonData["accredit"].intValue
        cate_id = jsonData["cate_id"].stringValue
        comic_id = jsonData["comic_id"].intValue
        cover = jsonData["cover"].stringValue
        description = jsonData["description"].stringValue
        is_dub = jsonData["is_dub"].intValue
        is_vip = jsonData["is_vip"].intValue
        is_week = jsonData["is_week"].intValue
        last_update_time = jsonData["last_update_time"].intValue
        last_update_week = jsonData["last_update_week"].stringValue
        level = jsonData["level"].stringValue
        name = jsonData["name"].stringValue
        ori = jsonData["ori"].stringValue
        series_status = jsonData["series_status"].intValue
        short_description = jsonData["short_description"].stringValue
        status = jsonData["status"].intValue
        theme_ids = jsonData["theme_ids"].arrayObject as? [String]
        thread_id = jsonData["thread_id"].intValue
        type = jsonData["type"].intValue
        wideCover = jsonData["wideCover"].stringValue
        author = AuthorModel(jsonData: jsonData["author"])
        
        if let classT = jsonData["classifyTags"].arrayObject {
            for item in classT {
                let json = JSON(item)
                let model = ClassifyTagModel(jsonData: json)
                classifyTags.append(model)
            }
        }
    }
}

struct ClassifyTagModel {
    var argName: Int = 0
    var name: String?
    var argVal: Int = 0
    init(jsonData: JSON) {
        argName = jsonData["argName"].intValue
        name = jsonData["name"].stringValue
        argVal = jsonData["argVal"].intValue
    }
}

struct AuthorModel {
    var avatar: String?
    var id: Int = 0
    var name: String?
    init(jsonData:JSON) {
        avatar = jsonData["avatar"].stringValue
        id = jsonData["id"].intValue
        name = jsonData["name"].stringValue
    }
}

struct ChapterSatticModel {
    var chapter_id: Int = 0
    var countImHightArr: Int = 0
    var has_locked_image: Int = 0
    var imHightArr = [[ImHightModel]]()
    var image_total: Int = 0
    var is_new: Int = 0
    var name: String
    var pass_time: Int = 0
    var price: Int = 0
    var release_time: Int = 0
    var size: Int = 0
    var type: Int = 0
    var zip_high_webp: Int = 0
    init(jsonData:JSON) {
        chapter_id = jsonData["chapter_id"].intValue
        countImHightArr = jsonData["countImHightArr"].intValue
        has_locked_image = jsonData["has_locked_image"].intValue
        image_total = jsonData["image_total"].intValue
        is_new = jsonData["is_new"].intValue
        name = jsonData["name"].stringValue
        pass_time = jsonData["pass_time"].intValue
        price = jsonData["price"].intValue
        release_time = jsonData["release_time"].intValue
        size = jsonData["size"].intValue
        type = jsonData["type"].intValue
        zip_high_webp = jsonData["zip_high_webp"].intValue
        if let imageHA = jsonData["imHightArr"].arrayObject {
            for item in imageHA {
                let json = JSON(item)
                let model = ImHightModel(jsonData: json)
                imHightArr.append([model])
            }
        }
    }
}

struct OtherWorksModel {
    var comicId: Int = 0
    var coverUrl: String?
    var name: String?
    var passChapterNum: Int = 0
    init(jsonData: JSON) {
        comicId = jsonData["comicId"].intValue
        coverUrl = jsonData["coverUrl"].stringValue
        name = jsonData["name"].stringValue
        passChapterNum = jsonData["passChapterNum"].intValue
    }
}

struct ImHightModel {
    var height: Int = 0
    var width: Int = 0
    init(jsonData: JSON) {
        height = jsonData["height"].intValue
        width = jsonData["width"].intValue
    }
}

////=======================================
struct DetailRealtimeModel {
    var comic : ComicRealtimeModel?
    var chapter_list = [ChapterRealtimeModel]()
    init(jsonData: JSON) {
        comic = ComicRealtimeModel(jsonData: jsonData["comic"])
        if let chap = jsonData["chapter_list"].arrayObject {
            for item in chap {
                let json = JSON(item)
                let model = ChapterRealtimeModel(jsonData: json)
                chapter_list.append(model)
            }
        }
    }
}

struct ComicRealtimeModel {
    var click_total: String?
    var comic_id: Int = 0
    var comment_total: Int = 0
    var favorite_total: String?
    var gift_total: Int = 0
    var is_auto_buy: Int = 0
    var is_free: Int = 0
    var is_vip_buy: Int = 0
    var is_vip_free: Int = 0
    var monthly_ticket: String?
    var status: Int = 0
    var total_ticket: String?
    var total_tucao: Int = 0
    var user_id: Int = 0
    var vip_discount:String?
    init(jsonData: JSON) {
        click_total = jsonData["click_total"].stringValue
        comic_id = jsonData["comic_id"].intValue
        comment_total = jsonData["comment_total"].intValue
        favorite_total = jsonData["favorite_total"].stringValue
        gift_total = jsonData["gift_total"].intValue
        is_auto_buy = jsonData["is_auto_buy"].intValue
        is_free = jsonData["is_free"].intValue
        is_vip_buy = jsonData["is_vip_buy"].intValue
        is_vip_free = jsonData["is_vip_free"].intValue
        monthly_ticket = jsonData["monthly_ticket"].stringValue
        status = jsonData["status"].intValue
        total_ticket = jsonData["total_ticket"].stringValue
        total_tucao = jsonData["total_tucao"].intValue
        user_id = jsonData["user_id"].intValue
        vip_discount = jsonData["vip_discount"].stringValue
    }
}

struct ChapterRealtimeModel {
    var buy_price: Int = 0
    var buyed: Int = 0
    var chapter_id: Int = 0
    var is_free: Int = 0
    var is_view: Int = 0
    var read_state: Int = 0
    var vip_images: Int = 0
    init(jsonData: JSON) {
        buy_price = jsonData["buy_price"].intValue
        buyed = jsonData["buyed"].intValue
        chapter_id = jsonData["chapter_id"].intValue
        is_free = jsonData["is_free"].intValue
        is_view = jsonData["is_view"].intValue
        read_state = jsonData["read_state"].intValue
        vip_images = jsonData["vip_images"].intValue
    }
}

////=====================
struct LoveModel {
    var normal: Bool = false
    var last_modified: Int = 0
    var comics = [LoveComicsModel]()
    init(jsonData:JSON) {
        normal = jsonData["normal"].boolValue
        last_modified = jsonData["last_modified"].intValue
        if let com = jsonData["comics"].arrayObject {
            for item in com {
                let json = JSON(item)
                let model = LoveComicsModel(jsonData: json)
                comics.append(model)
            }
        }
    }
}

struct LoveComicsModel {
    var accredit: Int = 0
    var affiche: String?
    var author_name: String?
    var cate_id: Int = 0
    var chapter_count: Int = 0
    var comic_id: Int = 0
    var cover: String?
    var create_time: Int = 0
    var description: String?
    var group_ids: Int = 0
    var last_update_time: Int = 0
    var name: String?
    var new_comic: Int = 0
    var read_order: Int = 0
    var series_status: Int = 0
    var short_description: String?
    var theme_ids: String?
    var user_id: Int = 0
    init(jsonData: JSON) {
        accredit = jsonData["accredit"].intValue
        affiche = jsonData["affiche"].stringValue
        author_name = jsonData["author_name"].stringValue
        cate_id = jsonData["cate_id"].intValue
        chapter_count = jsonData["chapter_count"].intValue
        comic_id = jsonData["comic_id"].intValue
        cover = jsonData["cover"].stringValue
        create_time = jsonData["create_time"].intValue
        description = jsonData["description"].stringValue
        group_ids = jsonData["group_ids"].intValue
        last_update_time = jsonData["last_update_time"].intValue
        name = jsonData["name"].stringValue
        new_comic = jsonData["new_comic"].intValue
        read_order = jsonData["read_order"].intValue
        series_status = jsonData["series_status"].intValue
        short_description = jsonData["short_description"].stringValue
        theme_ids = jsonData["theme_ids"].stringValue
        user_id = jsonData["user_id"].intValue
    }
}

/////===================
struct CommentListModel {
    var commentCount: Int = 0
    var commentList = [CommentModel]()
    var hasMore: Bool = false
    var objectId: Int = 0
    var objectType: String?
    var page: Int = 0
    var pageCount: Int = 0
    var serverNextPage: Int = 0
    init(jsonData: JSON) {
        commentCount = jsonData["commentCount"].intValue
        hasMore = jsonData["hasMore"].boolValue
        objectId = jsonData["objectId"].intValue
        objectType = jsonData["objectType"].stringValue
        page = jsonData["page"].intValue
        pageCount = jsonData["pageCount"].intValue
        serverNextPage = jsonData["serverNextPage"].intValue
        if let comment = jsonData["commentList"].arrayObject {
            for item in comment {
                let json = JSON(item)
                let model = CommentModel(jsonData: json)
                commentList.append(model)
            }
        }
    }
}

struct CommentModel {
    var cate: Int = 0
    var color: String?
    var comic_author: Int = 0
    var comment_from: Int = 0
    var comment_id: Int = 0
    var content: String?
    var content_filter: String?
    var create_time: Int = 0
    var create_time_str: String?
    var exp: String?
    var face: String?
    var face_type: Int = 0
    var floor: Int = 0
    var gift_img: String?
    var gift_num: Int = 0
    var group_admin: Int = 0
    var group_author: Int = 0
    var group_custom: String?
    var group_user: Int = 0
    var id: Int = 0
    var imageList: [Any]?
    var ip: String?
    var is_choice: Bool = true
    var is_delete: Bool = true
    var is_lock: Bool = true
    var is_up: Bool = false
    var likeCount: Int = 0
    var likeState: Int = 0
    var nickname: String?
    var online_time: Int = 0
    var praise_total: Int = 0
    var sex: String?
    var ticketNum: Int = 0
    var title: Int = 0
    var total_reply: Int = 0
    var user_id: Int = 0
    var vip_exp: Int = 0
    init(jsonData:JSON) {
        cate = jsonData["cate"].intValue
        color = jsonData["color"].stringValue
        comic_author = jsonData["comic_author"].intValue
        comment_from = jsonData["comment_from"].intValue
        comment_id = jsonData["comment_id"].intValue
        content = jsonData["content"].stringValue
        content_filter = jsonData["content_filter"].stringValue
        create_time = jsonData["create_time"].intValue
        create_time_str = jsonData["create_time_str"].stringValue
        exp = jsonData["exp"].stringValue
        face = jsonData["face"].stringValue
        face_type = jsonData["face_type"].intValue
        floor = jsonData["floor"].intValue
        gift_img = jsonData["gift_img"].stringValue
        gift_num = jsonData["gift_num"].intValue
        group_admin = jsonData["group_admin"].intValue
        group_author = jsonData["group_author"].intValue
        group_custom = jsonData["group_custom"].stringValue
        group_user = jsonData["group_user"].intValue
        id = jsonData["id"].intValue
        imageList = jsonData["imageList"].arrayObject
        ip = jsonData["ip"].stringValue
        is_choice = jsonData["is_choice"].boolValue
        is_delete = jsonData["is_delete"].boolValue
        is_lock = jsonData["is_lock"].boolValue
        is_up = jsonData["is_up"].boolValue
        likeCount = jsonData["likeCount"].intValue
        likeState = jsonData["likeState"].intValue
        nickname = jsonData["nickname"].stringValue
        online_time = jsonData["online_time"].intValue
        praise_total = jsonData["praise_total"].intValue
        sex = jsonData["sex"].stringValue
        ticketNum = jsonData["ticketNum"].intValue
        title = jsonData["title"].intValue
        total_reply = jsonData["total_reply"].intValue
        user_id = jsonData["user_id"].intValue
        vip_exp = jsonData["vip_exp"].intValue
    }
}

struct LevelModel {
    var album_size: Int = 0
    var exp_speed: String?
    var favorite_num: Int = 0
    var level: Int = 0
    var max: Int = 0
    var min_exp: Int = 0
    var ticket: Int = 0
    var wage: Int = 0
    init(jsonData:JSON) {
        album_size = jsonData["album_size"].intValue
        exp_speed = jsonData["exp_speed"].stringValue
        favorite_num = jsonData["favorite_num"].intValue
        level = jsonData["level"].intValue
        max = jsonData["max"].intValue
        min_exp = jsonData["min_exp"].intValue
        ticket = jsonData["ticket"].intValue
        ticket = jsonData["ticket"].intValue
        wage = jsonData["wage"].intValue
    }
}

//////=========
struct ChapterModel {
    var chapter_id: Int = 0
    var status: Int = 0
    var type: Int = 0
    var image_list = [ImageListModel]()
    init(jsonData:JSON) {
        chapter_id = jsonData["chapter_id"].intValue
        status = jsonData["status"].intValue
        type = jsonData["type"].intValue
        if let imageList = jsonData["image_list"].arrayObject {
            for item in imageList {
                let json = JSON(item)
                let model = ImageListModel(jsonData: json)
                image_list.append(model)
            }
        }
    }
}

struct ImageListModel {
    var height: Int = 0
    var image_id: Int = 0
    var images = [ImageModel]()
    var img05: String?
    var img50: String?
    var location: String?
    var total_tucao: Int = 0
    var type: Int = 0
    var webp: Int = 0
    var width: Int = 0
    init(jsonData: JSON) {
        height = jsonData["height"].intValue
        image_id = jsonData["image_id"].intValue
        img05 = jsonData["img05"].stringValue
        img50 = jsonData["img50"].stringValue
        location = jsonData["location"].stringValue
        total_tucao = jsonData["total_tucao"].intValue
        type = jsonData["type"].intValue
        webp = jsonData["webp"].intValue
        width = jsonData["width"].intValue
        if let imageS = jsonData["images"].arrayObject {
            for item in imageS {
                let json = JSON(item)
                let model = ImageModel(jsonData: json)
                images.append(model)
            }
        }
    }
}

struct ImageModel {
    var height: Int = 0
    var id: Int = 0
    var img05: String?
    var img50: String?
    var sort: Int = 0
    var width: Int = 0
    init(jsonData:JSON) {
        height = jsonData["height"].intValue
        id = jsonData["id"].intValue
        img05 = jsonData["img05"].stringValue
        img50 = jsonData["img50"].stringValue
        sort = jsonData["sort"].intValue
        width = jsonData["width"].intValue
    }
}




